package com.xbongbong.saas.domain.entity;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.io.Serializable;

/**
 * @author long.rao
 * @version v1.0
 * @date 2019/2/23 15:28
 * @since v1.0
 */
@Getter
@Setter
@ToString
public class ContractProductEntity extends BusinessUnitProductEntity implements Serializable {

    private static final long serialVersionUID = -7518928338926821340L;

    private Long id;
    // 公司ID
    private String corpid;
    // 表单id
    private Long formId;
    // 合同ID
    private Long contractId;
    // 产品ID
    private Long parentId;
    // 产品ID
    private Long productId;
    // 产品数量
    private Double productNum;
    // 产品名称
    private String productName;
    //产品编号
    private String productNo;
    // 销售价格： 默认是-1，不显示价格
    private Double price;
    //单位
    private String productUnit;
    // 折扣
    private Double discount;
    // 产品规格
    private String specification;
    //产品图片
    private String productThumbnail;
    //产品备注
    private String memo;
    // 产品成本
    private Double cost;
    //条码
    private String barcode;
    // 排序
    private Integer sort;
    // 添加时间
    private Long addTime;
    // 更新时间
    private Long updateTime;
    // 删除标记
    private Integer del;
    //代表该合同产品是显示在待生产列表还是待采购列表，1：待生产列表；0：待采购列表，默认0
    private Integer isProduce;
    //合同类型
    private Integer type;
    // 产品历史单价
    private Double historicalPrice;
//    //产品总销售额
    private Double sumPrice = 0d;//对应mapper内的配置字段
//    //总成本--对应mapper内的配置字段
    private Double sumCost = 0d;

    /**
     * 合同已出库数量,用于计算,历史原因
     */
    private Double outstockNum;
    /**
     * 合同已出库数量，用于展示
     */
    private Double contractOutstockNum;
    /**
     * 待采购合同扩展字段：当前产品总库存
     */
    private Double total;
    /**
     * 待采购合同扩展字段：当前产品在该合同的总数量
     */
    private Double sumNum;

    private JSONObject data;
    /**
     * 上游关联产品数据id
     */
    private Long refProductId;
    /**
     * 退货数量或退货退款入库数量
     */
    private Double instockNum;

    private Double waitOutStockNum;

    private JSONArray productPriceArr;
    // 发货数量
    private Double shipmentsNum;
    // 在待系列状态可用
    private Integer status;
    // 待采购缺货数量
    private Double purchaseNum;

    public ContractProductEntity() {
        long now = DateTimeUtil.getInt();
        this.corpid = "";
        this.contractId = 0L;
        this.productId = 0L;
        this.productNum = 0d;
        this.productName = "";
        this.price = 0D;
        this.specification = "";
        this.discount = 100d;
        this.memo = "";
        this.sort = 0;
        this.isProduce = 0;

        this.addTime = now;
        this.updateTime = now;
        this.del = 0;
        this.cost = 0D;
        this.contractOutstockNum = 0D;
        this.instockNum = 0D;
        this.outstockNum = 0D;
        this.data = new JSONObject();
        this.waitOutStockNum = 0D;
        this.shipmentsNum = 0D;
        this.status=0;
        this.purchaseNum=0D;
    }

    public ContractProductEntity(boolean isEmpty) {

    }
}
